function doCompleteTask(outcome, formaction, formid) {
	var opinionele = null;
	if (PROCESS_FORM_OPINION_ID != null) {
		opinionele = document.getElementById(PROCESS_FORM_OPINION_ID);
		if (PROCESS_FORM_OPINION_MIRROR_ID != null) {
			doCopyOpinion();
		}
	}
	if (TASKINSTANCE_OPINION_EMPTY_CHECK && opinionele != null) {
		if (PROCESS_FORM_OPINION_TYPE == 'ckeditor') {
			var opinion_data = $.trim(OPINION_CKEDITOR_INSTANCE.getData());
			if (opinion_data == null || opinion_data == '') {
				doNotifition(TASKINSTANCE_OPINION_EMPTY_ALERT);
				OPINION_CKEDITOR_INSTANCE.focus();
				return false;
			}
		} else {
			if (opinionele.value == '' || $.trim(opinionele.value).length == 0) {
				doNotifition(TASKINSTANCE_OPINION_EMPTY_ALERT);
				opinionele.focus();
				return false;
			}
		}
	}
	if (opinionele != null && TASKINSTANCE_OPINION_MINLENGTH > 0) {
		if (PROCESS_FORM_OPINION_TYPE == 'ckeditor') {
			var opinion_data = $.trim(OPINION_CKEDITOR_INSTANCE.getData());
			if (opinion_data.length < TASKINSTANCE_OPINION_MINLENGTH) {
				doNotifition(TASKINSTANCE_OPINION_MINLENGTH_ALERT
						+ TASKINSTANCE_OPINION_MINLENGTH + '!');
				OPINION_CKEDITOR_INSTANCE.focus();
				return false;
			}
		} else {
			if (opinionele.value.length < TASKINSTANCE_OPINION_MINLENGTH) {
				doNotifition(TASKINSTANCE_OPINION_MINLENGTH_ALERT
						+ TASKINSTANCE_OPINION_MINLENGTH + '!');
				opinionele.focus();
				return false;
			}
		}
	}
	if (opinionele != null && TASKINSTANCE_OPINION_MAXLENGTH > 0) {
		if (PROCESS_FORM_OPINION_TYPE == 'ckeditor') {
			var opinion_data = $.trim(OPINION_CKEDITOR_INSTANCE.getData());
			if (opinion_data.length > TASKINSTANCE_OPINION_MINLENGTH) {
				doNotifition(TASKINSTANCE_OPINION_MAXLENGTH_ALERT
						+ TASKINSTANCE_OPINION_MAXLENGTH + '!');
				OPINION_CKEDITOR_INSTANCE.focus();
				return false;
			}
		} else {
			if (opinionele.value.length > TASKINSTANCE_OPINION_MAXLENGTH) {
				doNotifition(TASKINSTANCE_OPINION_MAXLENGTH_ALERT
						+ TASKINSTANCE_OPINION_MAXLENGTH + '!');
				opinionele.focus();
				return false;
			}
		}
	}
	var submit_action = DEFAULT_TASKINSTANCE_FORM_SUBMIT_URL;
	var formele;
	var outcomeele = document
			.getElementById(PROCESS_INFORMATION_OUTCOME_ELEMENT_ID);
	outcomeele.value = outcome;
	if (formid != null) {
		formele = document.getElementById(formid);
	} else {
		formele = document.forms[0];
	}
	if (formaction != null) {
		formele.action = formaction;
	} else {
		formele.action = submit_action;
	}
	$('#TASKINSTANCE_FORM_COMMIT_CONFIRM_DIV_CONTENT').text(
			TASKINSTANCE_FORM_CONFIRM_MESSAGE_PART1 + '"' + outcome + '"'
					+ TASKINSTANCE_FORM_CONFIRM_MESSAGE_PART2);
	if (formele.onsubmit != null) {
		if (formele.onsubmit())
			doConfirm(outcome);
	} else {
		doConfirm(outcome);
	}
}

function doCopyOpinion() {
	if (PROCESS_FORM_OPINION_ID != null
			&& PROCESS_FORM_OPINION_MIRROR_ID != null) {
		var mirrorele = document.getElementById(PROCESS_FORM_OPINION_MIRROR_ID);
		if (PROCESS_FORM_OPINION_TYPE == 'ckeditor') {
			mirrorele.value = $.trim(OPINION_CKEDITOR_INSTANCE.getData());
		} else {
			var opinionele = document.getElementById(PROCESS_FORM_OPINION_ID);
			mirrorele.value = opinionele.value;
		}
	}
}

function doCopyOutcome(outcome) {
	var outcomeele = document
			.getElementById(PROCESS_INFORMATION_OUTCOME_ELEMENT_ID);
	outcomeele.value = outcome;
}

function doSubmitForm(formid, formaction) {
	var outcomeele = document
			.getElementById(PROCESS_INFORMATION_OUTCOME_ELEMENT_ID);
	if (outcomeele == null || outcomeele.value.length == 0) {
		alert("Please select one outcome!");
		return;
	}
	var submit_action = DEFAULT_TASKINSTANCE_FORM_SUBMIT_URL;
	var formele;
	if (formid != null) {
		formele = document.getElementById(formid);
	} else {
		formele = document.forms[0];
	}

	if (formaction != null) {
		formele.action = formaction;
	} else {
		formele.action = submit_action;
	}
	formele.submit();
}

function doUnBlock() {
	$.unblockUI();
}

function doConfirm(outcome) {
	var top_ = calculateTop();
	$.blockUI( {
		message : $('#TASKINSTANCE_FORM_COMMIT_CONFIRM_DIV'),
		centerY : false,
		css : {
			width : '350px',
			top : top_,
			border : 'none',
			padding : '5px',
			backgroundColor : '#000000',
			'-webkit-border-radius' : '10px',
			'-moz-border-radius' : '10px',
			opacity : .6,
			color : '#ffffff'
		}
	});
}

function doBlockForm() {
	var top_ = calculateTop();
	$.blockUI( {
		message : $('#TASKINSTANCE_FORM_COMMIT_COMMITING_MESSAGE_DIV'),
		centerY : false,
		css : {
			width : '350px',
			top : top_,
			right : '10px',
			border : 'none',
			padding : '5px',
			backgroundColor : '#000000',
			'-webkit-border-radius' : '10px',
			'-moz-border-radius' : '10px',
			opacity : .6,
			color : '#ffffff'
		}
	});
}

function calculateTop() {
	var top_ = parent.document.body.scrollTop;
	if (top_ == 0) {
		top_ += 10;
	}
	return top_;
}

function doNotifition(context) {
	var top_ = calculateTop();

	$.blockUI( {
		message : context,
		fadeIn : 700,
		fadeOut : 700,
		timeout : 2000,
		showOverlay : false,
		centerY : false,
		css : {
			width : '350px',
			top : top_,
			left : '',
			right : '10px',
			border : 'none',
			padding : '5px',
			backgroundColor : '#000000',
			'-webkit-border-radius' : '10px',
			'-moz-border-radius' : '10px',
			opacity : .6,
			color : '#ffffff'
		}
	});
}

function doAppendToFckeditor(path, width, height) {
	try {
		if (width >= 400) {
			width = 400;
		}
		if (height >= 300) {
			height = 300;
		}
		var imagePath = PROCESS_IMAGE_PART3 + path + "'>" + PROCESS_IMAGE_PART2
				+ path + "' height='" + height + "' width='" + width
				+ "'\/></a>";
		OPINION_CKEDITOR_INSTANCE.insertHtml(imagePath);
	} catch (e) {
		alert(e.message);
	}
}